package cn.ljy.uem.service.impl;

import cn.ljy.authority.service.impl.IBaseService;
import cn.ljy.common.exception.model.MyWebException;
import cn.ljy.uem.dao.ProjectRoleMapper;
import cn.ljy.uem.model.ProjectRole;
import cn.ljy.uem.model.query.ProjectRoleQuery;
import cn.ljy.uem.service.ProjectRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * @description 工程角色
 * @author 廖振豪
 * @date 2023-1-17
 */
@Service
@Slf4j
public class IProjectRoleService extends IBaseService<ProjectRole, ProjectRoleQuery> implements ProjectRoleService {

    @Autowired
    private ProjectRoleMapper mapper;

    @Override
    protected void beforeGet(Serializable id) {
    }

    @Override
    protected void beforeUpdate(ProjectRole projectRole) {

    }

    @Override
    protected void beforeSave(ProjectRole projectRole) {
        if(mapper.countByName(projectRole.getName())>0){
            throw new MyWebException("添加失败：该角色已经存在");
        }
    }

    @Override
    protected void beforeDelete(Serializable[] ids) {

    }
}
